<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>路由router的基本使用</title>
</head>
<body>
<div id="app">
    <a href="#/login">点我登录</a>
    <a href="#/register">点我注册</a>
<!--    显示路由的组件-->
    <router-view>

    </router-view>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-router@3.4.9/dist/vue-router.js"></script>
<script>
    //声明组件
    const login = {
        template:'<h1>登录</h1>'
    }
    const register = {
        template: '<h1>注册</h1>'
    }
    //创建路由对象
    const router = new VueRouter({
        routes:[
            {path:'/login',component:login},
            {path: '/register',component:register}
        ]
    })
    const app = new Vue({
        el: "#app",
        data: {},
        methods: {},
        //设置路由对象
        router:router
    });
</script>
</html>
